package com.flight.trans.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flight.trans.R;
import com.flight.trans.base.BaseRecyclerAdapter;
import com.flight.trans.base.BaseViewHolder;
import com.flight.trans.bean.LeavePortDuplicateBean.LeavePortDuplicateData;
import com.flight.trans.util.CommonUtils;

import java.util.List;

/**
 * 出港复重
 */
public class LeavePortDuplicateAdapter extends BaseRecyclerAdapter<LeavePortDuplicateData> {

    public LeavePortDuplicateAdapter(Context mContext, List<LeavePortDuplicateData> mList) {
        super(mContext, mList);
    }

    @Override
    public int setContentView() {
        return R.layout.adapter_leave_port_duplicate;
    }

    @Override
    protected void bindData(BaseViewHolder holder, LeavePortDuplicateData data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);
        TextView mTvFlightNo = holder.findViewById(R.id.mTvFlightNo);
        TextView mTvPlanTime = holder.findViewById(R.id.mTvPlanTime);
        TextView mTvRouteLine = holder.findViewById(R.id.mTvRouteLine);
        TextView mTvDispenseCount = holder.findViewById(R.id.mTvDispenseCount);
        TextView mTvDispenseWeight = holder.findViewById(R.id.mTvDispenseWeight);
        TextView mTvDispensePerson = holder.findViewById(R.id.mTvDispensePerson);
        TextView mTvContainerCount = holder.findViewById(R.id.mTvContainerCount);
        TextView mTvGroupBoardPerson = holder.findViewById(R.id.mTvGroupBoardPerson);

        CommonUtils.setScreenViewVisible(mTvDispenseCount);
        CommonUtils.setScreenViewVisible(mTvDispenseWeight);
        CommonUtils.setScreenViewVisible(mTvContainerCount);

        mTvFlightNo.setText(data.getFlightNo());
        mTvPlanTime.setText(CommonUtils.getTimeNorm(data.getStd()));
        mTvRouteLine.setText(data.getDeap());

        mTvDispenseCount.setText(String.valueOf(data.getDispenseNum()));
        mTvDispenseWeight.setText(String.valueOf(data.getDispenseWeight()));
        mTvDispensePerson.setText(data.getDispenseUserName());

        mTvContainerCount.setText(String.valueOf(data.getOutboundCnt()));
        mTvGroupBoardPerson.setText(data.getAssembleUserName());

        mLlContainerItem.setBackground(mContext.getDrawable(data.isLocked() ? R.color.color_red : R.drawable.selector_cyan_line));

        setItemClickListener(mLlContainerItem , position);
    }
}
